﻿namespace WMS6.Web.Common
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI;
    using WMS6.Web.CommonMethodServiceRef;

    public class WareHouseShowAjax : Page
    {
        private int LocNum = 0;
        private int MaxLateral = 0;
        private int MaxLoc = 1;
        private string ShowEffect = "";
        private List<string> strColorList = new List<string> { "areaA", "areaB", "areaC", "areaD", "areaE", "areaF", "areaG", "areaH", "areaI", "areaJ", "areaK", "areaL" };
        private string[] strLocArray = new string[] { 
            "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", 
            "D", "H", "I", "G", "K", "M", "L", "N", "O", "P", "Q", "R", "S", "T", "U", "V", 
            "W", "X", "Y", "Z"
         };
        private StringBuilder strZoneColor = new StringBuilder();
        private int ZoneNum = 0;

        private void AssignFunctionResponse(string StrHtml)
        {
            string strType = base.Request.QueryString["TYPE"];
            base.Response.Clear();
            base.Response.StatusCode = 200;
            base.Response.StatusDescription = "OK";
            base.Response.ContentType = "text/html";
            base.Response.Write(strType + "@_@" + StrHtml);
            base.Response.Flush();
            base.Response.End();
            base.Response.Close();
        }

        private int ConvertToIntByValue(string value)
        {
            for (int i = 0; this.strLocArray.Length > i; i++)
            {
                if (this.strLocArray[i] == value)
                {
                    return i;
                }
            }
            return 0;
        }

        private string ConvertToStringByIndex(int Index)
        {
            return this.strLocArray[Index].ToString();
        }

        private void GetDataDetailById(string LocID)
        {
            List<VisualLocationInfo> visualLoc = this.Session["VisualLocSession"] as List<VisualLocationInfo>;
            StringBuilder strDiv = new StringBuilder();
            foreach (VisualLocationInfo info in visualLoc)
            {
                if (info.Loc == LocID)
                {
                    strDiv.Append(" <table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
                    strDiv.Append("    <td width=\"10\" height=\"10\"><img src=\"../Images/area_bg_01.gif\" width=\"10\" height=\"10\"></td>");
                    strDiv.Append("  <td colspan=\"3\" background=\"../Images/area_bg_02.gif\"></td>");
                    strDiv.Append("  <td width=\"10\" height=\"10\"><img src=\"../Images/area_bg_03.gif\" width=\"10\" height=\"10\"></td>  </tr>  <tr>");
                    strDiv.Append("  <td width=\"10\" background=\"../Images/area_bg_04.gif\"></td>");
                    strDiv.Append("  <td colspan=\"3\" background=\"../Images/area_bg_05.gif\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">   <tr>");
                    strDiv.AppendFormat(" <td width=\"24%\" class=\"areaname\">储区：</td>  <td class=\"areamessage\">{0}</td>  </tr> ", info.ZoneID);
                    strDiv.AppendFormat(" <tr><td class=\"areaname\">货位：</td><td class=\"areamessage\">{0}</td></tr>", info.Loc);
                    strDiv.AppendFormat(" <tr><td class=\"areaname\">状态：</td> <td class=\"areamessage\">{0}</td></tr>", info.Status);
                    strDiv.AppendFormat(" <tr><td class=\"areaname\" colspan=2 >{0}</td></tr></table></td>", this.LocationEmploy(info));
                    strDiv.Append(" <td width=\"10\" background=\"../Images/area_bg_06.gif\"></td></tr><tr>");
                    strDiv.Append("   <td width=\"10\"><img src=\"../Images/area_bg_07.gif\" width=\"10\" height=\"31\"></td>");
                    strDiv.Append(" <td width=\"55%\" background=\"../Images/area_bg_08.gif\">&nbsp;</td>");
                    strDiv.Append(" <td width=\"28\"><img src=\"../Images/area_bg_09.gif\" width=\"27\" height=\"31\"></td>");
                    strDiv.Append("  <td width=\"45%\" background=\"../Images/area_bg_08.gif\">&nbsp;</td>");
                    strDiv.Append("    <td width=\"10\"><img src=\"../Images/area_bg_10.gif\" width=\"10\" height=\"31\"></td>");
                    strDiv.Append("</tr></table>");
                }
            }
            this.AssignFunctionResponse(strDiv.ToString());
        }

        private void GetLocDataByWh()
        {
        }

        private void GetSkuDataById(string LocID)
        {
            VisualLocationInfo visualLoc = (this.Session["VisualLocSession"] as List<VisualLocationInfo>).Find(x => x.Loc == LocID);
            StringBuilder strDiv = new StringBuilder();
            strDiv.Append("<table width=\"500\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"34\" background=\"../Images/slotbg_01.gif\"><table width=\"94%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><span class=\"warehoustitle\">详细信息</span></td><td width=\"16\" class=\"close\" onclick=\"LocAndSkuClose();\">&nbsp;</td>  </tr></table></td></tr>");
            strDiv.Append("<tr><td height=\"22\" background=\"../Images/slotbg_03.gif\"><table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\"><tr>");
            strDiv.AppendFormat("<td width=\"10%\" class=\"areaname\">储区：</td><td class=\"areamessage\">{0}</td><td width=\"15%\" class=\"areaname\">种类：</td> <td class=\"areamessage\">{1}</td></tr>", visualLoc.ZoneID, visualLoc.LocCategory);
            strDiv.AppendFormat("   <tr><td class=\"areaname\">货位：</td><td class=\"areamessage\">{0}</td><td class=\"areaname\">属性：</td><td class=\"areamessage\">{1}</td></tr>", visualLoc.Loc, visualLoc.LocFlag);
            strDiv.AppendFormat("  <tr><td class=\"areaname\">状态：</td><td class=\"areamessage\">{0}</td><td class=\"areaname\">用途：</td><td class=\"areamessage\">{1}</td></tr>", visualLoc.Status, visualLoc.LocUsage);
            strDiv.AppendFormat(" <tr> <td class=\"areaname\">容量：</td> <td class=\"areamessage\">{0}</td><td class=\"areaname\">处理方式：</td><td class=\"areamessage\">{1}</td></tr> ", visualLoc.CubicCapacity, visualLoc.LocHandling);
            strDiv.Append(" </table></td></tr>");
            strDiv.Append("<tr><td height=\"7\" background=\"../Images/slotbg_02.gif\"></td></tr>");
            strDiv.Append("<tr><td background=\"../Images/slotbg_03.gif\" > <div style=\"overflow-y:auto; height:120px; width:98%;\"><table width=\"94%\" border=\"0\" align=\"right\" cellpadding=\"0\" cellspacing=\"0\"> ");
            strDiv.Append("</table></div></td></tr><tr><td height=\"18\" background=\"../Images/slotbg_04.gif\">&nbsp;</td></tr></table>");
            this.AssignFunctionResponse(strDiv.ToString());
        }

        private string LocationCount(string Loc)
        {
            string strIndex = string.Empty;
            Loc = Loc.Replace("=", "");
            Loc = Loc.Replace("!", "");
            Loc = Loc.Replace("@", "");
            Loc = Loc.Replace("#", "");
            Loc = Loc.Replace("$", "");
            Loc = Loc.Replace("%", "");
            Loc = Loc.Replace("^", "");
            Loc = Loc.Replace("&", "");
            Loc = Loc.Replace("*", "");
            Loc = Loc.Replace("(", "");
            Loc = Loc.Replace(")", "");
            Loc = Loc.Replace("~", "");
            Loc = Loc.Replace("?", "");
            Loc = Loc.Replace(",", "");
            Loc = Loc.Replace(".", "");
            Loc = Loc.Replace("<", "");
            Loc = Loc.Replace(">", "");
            Loc = Loc.Replace("+", "");
            Loc = Loc.Replace("`", "");
            Loc = Loc.Replace("_", "");
            Loc = Loc.Replace("/", "");
            Loc = Loc.Replace(",", "");
            Loc = Loc.Replace("-", "");
            for (int i = 0; Loc.Length > i; i++)
            {
                char CS00001 = Loc[i];
                strIndex = strIndex + this.ConvertToIntByValue(CS00001.ToString());
            }
            return strIndex;
        }

        private string LocationEmploy(VisualLocationInfo info)
        {
            StringBuilder strCubicCapacity = new StringBuilder();
            if (info.CubicCapacity == 0.0)
            {
                strCubicCapacity.Append("<span style=\"color:#96f15d\">空闲率</span>：0% &nbsp;<span style=\"color:Red\">占用率</span>：0%");
            }
            else
            {
                long z = Convert.ToInt64((double) (((info.CubicCount * 100.0) / (info.CubicCapacity * 100.0)) * 100.0));
                long k = ((100 - z) < 0) ? 0 : (100 - z);
                strCubicCapacity.AppendFormat("<span style=\"color:#00FF00\">空闲率</span>：{0}% &nbsp;<span style=\"color:Red\">占用率</span>：{1}%", k, z);
            }
            return strCubicCapacity.ToString();
        }

        private string LocationHtmlCreate(string strZoneName, List<VisualLocationInfo> VisualLocation)
        {
            StringBuilder LocHtml = new StringBuilder();
            LocHtml.Append(" <div style=\"float:left; width:@DivWidth%\">");
            LocHtml.Append("  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">");
            string StrLocIndex = string.Empty;
            int iLocCount = 0;
            foreach (VisualLocationInfo info in VisualLocation)
            {
                if (info.ZoneID == strZoneName)
                {
                    string strLoc = this.LocationCount(info.Loc);
                    if (!string.IsNullOrEmpty(StrLocIndex))
                    {
                        if ((Convert.ToInt64(StrLocIndex) + 1) == Convert.ToInt64(strLoc))
                        {
                            LocHtml.Append("<tr>");
                            LocHtml.AppendFormat(" <td class=\"{2}\" title=\"{1}\" id=\"td_{0}\"   onclick=\"LocAndSkuShow('{0}');\" onmouseout=\"LocDetailClose();\"   onmouseover=\"javascript:LocDetailLoc('{0}');\" >{0}</td>", info.Loc, info.LocUsage, this.LocVolume(info));
                            LocHtml.Append("</tr>");
                            StrLocIndex = strLoc;
                        }
                        else
                        {
                            iLocCount++;
                            LocHtml.Append(" </table></div>");
                            if (iLocCount == 10)
                            {
                                this.MaxLoc = 10;
                                this.MaxLateral++;
                                LocHtml.Append("<div class=\"corridor_row\"></div>");
                                iLocCount = 0;
                            }
                            LocHtml.Append(" <div style=\"float:left;width:@DivWidth%\">");
                            LocHtml.Append("  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">");
                            LocHtml.Append("<tr>");
                            LocHtml.AppendFormat(" <td class=\"{2}\" title=\"{1}\" id=\"td_{0}\"  onclick=\"LocAndSkuShow('{0}');\" onmouseout=\"LocDetailClose();\"    onmouseover=\"javascript:LocDetailLoc('{0}');\">{0}</td>", info.Loc, info.LocUsage, this.LocVolume(info));
                            LocHtml.Append("</tr>");
                            StrLocIndex = strLoc;
                        }
                    }
                    else
                    {
                        LocHtml.Append("<tr>");
                        LocHtml.AppendFormat(" <td class=\"{2}\" title=\"{1}\" id=\"td_{0}\"  onclick=\"LocAndSkuShow('{0}');\"  onmouseout=\"LocDetailClose();\"   onmouseover=\"javascript:LocDetailLoc('{0}');\" >{0}</td>", info.Loc, info.LocUsage, this.LocVolume(info));
                        LocHtml.Append("</tr>");
                        StrLocIndex = this.LocationCount(info.Loc);
                    }
                }
            }
            if (this.MaxLoc != 10)
            {
                this.MaxLoc = iLocCount + 1;
            }
            LocHtml.Append("   </table></div>");
            return LocHtml.ToString();
        }

        private void LocDataRemark(string strZone, string strColor)
        {
            this.strZoneColor.AppendFormat("<div  style=\"float:left\" class=\"areaname\">{0}:&nbsp;</div><div style=\"width:25px; height:10px; margin-right:20px;float:left\" class=\"{1}\">&nbsp;</div>", strZone, strColor);
        }

        public string LocVolume(VisualLocationInfo info)
        {
            string StrClassName = "default_bg";
            if (info.CubicCount == 0.0)
            {
                if (this.ShowEffect == "Solid")
                {
                    StrClassName = "stereo_nobg";
                }
                else
                {
                    StrClassName = "no_bg";
                }
            }
            else if (Convert.ToInt32(info.CubicCapacity) > Convert.ToInt32(info.CubicCount))
            {
                if (this.ShowEffect == "Solid")
                {
                    StrClassName = "stereo_somebg";
                }
                else
                {
                    StrClassName = "some_bg";
                }
            }
            else if (this.ShowEffect == "Solid")
            {
                StrClassName = "stereo_fullbg";
            }
            else
            {
                StrClassName = "full_bg";
            }
            if (!(info.Status.ToUpper() == "HOLD"))
            {
                return StrClassName;
            }
            if (this.ShowEffect == "Solid")
            {
                return "stereo_holdbg";
            }
            return "hold_bg";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            base.Response.Buffer = true;
            base.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1.0);
            base.Response.Expires = 0;
            base.Response.CacheControl = "no-cache";
            base.Response.AddHeader("Pragma", "No-Cache");
            this.ShowEffect = base.Request.QueryString["ShowEffect"];
            string CS40001 = base.Request.QueryString["TYPE"];
            if (CS40001 != null)
            {
                if (!(CS40001 == "Location"))
                {
                    if (CS40001 == "LocationDetail")
                    {
                        this.GetDataDetailById(base.Request.QueryString["LocationID"]);
                    }
                    else if (CS40001 == "SkuDetail")
                    {
                        this.GetSkuDataById(base.Request.QueryString["LocationID"]);
                    }
                    else if (CS40001 == "Query")
                    {
                        this.QueryLocData();
                    }
                }
                else
                {
                    this.GetLocDataByWh();
                }
            }
        }

        private void QueryLocData()
        {
            string strLoc = base.Request.QueryString["QueryLocID"];
            string strSkuID = base.Request.QueryString["QuerySkuID"];
            string strStatus = base.Request.QueryString["QueryStatus"];
            string strZoneID = base.Request.QueryString["QueryZoneID"];
            List<VisualLocationInfo> VisualLocation = this.Session["VisualLocSession"] as List<VisualLocationInfo>;
            if (((!string.IsNullOrEmpty(strLoc) || !string.IsNullOrEmpty(strSkuID)) || !string.IsNullOrEmpty(strStatus)) || !string.IsNullOrEmpty(strZoneID))
            {
                if (!string.IsNullOrEmpty(strZoneID))
                {
                    VisualLocation = VisualLocation.FindAll(x => x.ZoneID == strZoneID);
                }
                if (!string.IsNullOrEmpty(strLoc))
                {
                    VisualLocation = VisualLocation.FindAll(x => x.Loc == strLoc);
                }
                if (!string.IsNullOrEmpty(strSkuID))
                {
                    VisualLocation = VisualLocation.FindAll(x => x.InvLotLocLpnInfos.Exists(i => i.SkuID == strSkuID));
                }
                if (!string.IsNullOrEmpty(strStatus))
                {
                    VisualLocation = VisualLocation.FindAll(x => x.Status == strStatus);
                }
                if (VisualLocation.Count > 0)
                {
                    if (this.ShowEffect == "Solid")
                    {
                        this.SolidZoneHtmlCreate(VisualLocation);
                    }
                    else
                    {
                        this.ZoneHtmlCreate(VisualLocation);
                    }
                }
                else
                {
                    this.AssignFunctionResponse(" @_@<center  style=\"color:Red\" >没有找到合适的数据源！</center>");
                }
            }
            else if (this.ShowEffect == "Solid")
            {
                this.SolidZoneHtmlCreate(VisualLocation);
            }
            else
            {
                this.ZoneHtmlCreate(VisualLocation);
            }
        }

        private string SelectColor(string strZone)
        {
            string strColor = string.Empty;
            if (this.strColorList.Count > 0)
            {
                int i = 0;
                while (this.strColorList.Count > i)
                {
                    strColor = this.strColorList[i];
                    this.strColorList.RemoveAt(i);
                    this.LocDataRemark(strZone, strColor);
                    return strColor;
                }
            }
            return strColor;
        }

        private string SilidLocationHtmlCreate(string strZoneName, List<VisualLocationInfo> VisualLocation)
        {
            StringBuilder LocHtml = new StringBuilder();
            LocHtml.Append(" <div style=\"float:left; width:@DivWidth%\">");
            LocHtml.Append("  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">");
            string StrLocIndex = string.Empty;
            int iLocCount = 0;
            foreach (VisualLocationInfo info in VisualLocation)
            {
                if (info.ZoneID == strZoneName)
                {
                    string strLoc = this.LocationCount(info.Loc);
                    if (!string.IsNullOrEmpty(StrLocIndex))
                    {
                        if ((Convert.ToInt64(StrLocIndex) + 1) == Convert.ToInt64(strLoc))
                        {
                            LocHtml.Append("<tr><td width=\"8\"><img src=\"../Images/stereoM_01.gif\" width=\"8\" height=\"13\" /></td><td width=\"81%\" height=\"13\" background=\"../Images/stereoM_02.gif\"></td><td><img src=\"../Images/stereoM_03.gif\" width=\"12\" height=\"13\" /></td></tr>");
                            LocHtml.AppendFormat(" <tr><td height=\"18\" colspan=\"2\" background=\"../Images/stereo_bg.gif\" class=\"stereo_nobg\" id=\"td_{0}\" onclick=\"LocAndSkuShow('{0}');\"  onmouseout=\"LocDetailClose();\"   onmouseover=\"javascript:LocDetailLoc('{0}');\"  ><div class=\"{2}\">{0}</div></td>", info.Loc, info.LocUsage, this.LocVolume(info));
                            LocHtml.Append("<td background=\"../Images/stereoR_bg.gif\">&nbsp;</td></tr>");
                            StrLocIndex = strLoc;
                        }
                        else
                        {
                            iLocCount++;
                            LocHtml.Append(" </table></div>");
                            if (iLocCount == 10)
                            {
                                this.MaxLoc = 10;
                                this.MaxLateral++;
                                LocHtml.Append("<div class=\"corridor_row\"></div>");
                                iLocCount = 0;
                            }
                            LocHtml.Append(" <div style=\"float:left;width:@DivWidth%\">");
                            LocHtml.Append("  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">");
                            LocHtml.Append("<tr><td width=\"8\"><img src=\"../Images/stereoTop_01.gif\" width=\"8\" height=\"13\" /></td><td width=\"81%\" height=\"13\" background=\"../Images/stereoTop_02.gif\"></td><td><img src=\"../Images/stereoTop_03.gif\" width=\"12\" height=\"13\" /></td></tr>");
                            LocHtml.AppendFormat(" <tr><td height=\"18\" colspan=\"2\" background=\"../Images/stereo_bg.gif\" class=\"stereo_nobg\" id=\"td_{0}\" onclick=\"LocAndSkuShow('{0}');\"  onmouseout=\"LocDetailClose();\"   onmouseover=\"javascript:LocDetailLoc('{0}');\"  ><div class=\"{2}\">{0}</div></td>", info.Loc, info.LocUsage, this.LocVolume(info));
                            LocHtml.Append("<td background=\"../Images/stereoR_bg.gif\">&nbsp;</td></tr>");
                            StrLocIndex = strLoc;
                        }
                    }
                    else
                    {
                        LocHtml.Append("<tr><td width=\"8\"><img src=\"../Images/stereoTop_01.gif\" width=\"8\" height=\"13\" /></td><td width=\"81%\" height=\"13\" background=\"../Images/stereoTop_02.gif\"></td><td><img src=\"../Images/stereoTop_03.gif\" width=\"12\" height=\"13\" /></td></tr>");
                        LocHtml.AppendFormat(" <tr><td height=\"18\" colspan=\"2\" background=\"../Images/stereo_bg.gif\" class=\"stereo_nobg\" id=\"td_{0}\" onclick=\"LocAndSkuShow('{0}');\"  onmouseout=\"LocDetailClose();\"   onmouseover=\"javascript:LocDetailLoc('{0}');\"  ><div class=\"{2}\">{0}</div></td>", info.Loc, info.LocUsage, this.LocVolume(info));
                        LocHtml.Append("<td background=\"../Images/stereoR_bg.gif\">&nbsp;</td></tr>");
                        StrLocIndex = this.LocationCount(info.Loc);
                    }
                }
            }
            if (this.MaxLoc != 10)
            {
                this.MaxLoc = iLocCount + 1;
            }
            LocHtml.Append("   </table></div>");
            return LocHtml.ToString();
        }

        private string SkuHtmlConvert(List<InvSkuLocInfo> invSkuLoc)
        {
            StringBuilder strSku = new StringBuilder();
            strSku.Append("<tr><td>");
            if (invSkuLoc.Count > 0)
            {
                foreach (InvSkuLocInfo info in invSkuLoc)
                {
                    strSku.Append("<table width=\"32%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\"class=\"slotbox\" style=\"float:left; margin-right:5px;margin-top:5px;\">");
                    strSku.Append("<tr><td colspan=\"2\"><img src=\"../Images/box.gif\" width=\"40\" height=\"32\"></td></tr>");
                    strSku.AppendFormat("  <tr><td width=\"25%\" nowrap>数量：</td><td class=\"areamessage\">{0}</td></tr>", info.Qty.ToString("0.00"));
                    strSku.AppendFormat("  <tr><td width=\"25%\">名称：</td><td class=\"areamessage\">{0}</td></tr></table>", info.SkuID);
                }
            }
            else
            {
                strSku.Append("<table width=\"32%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" ><tr><td align=\"center\"  style=\"color:Red\">该货位没有货品记录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>");
            }
            strSku.Append("</td></tr>");
            return strSku.ToString();
        }

        private void SolidZoneHtmlCreate(List<VisualLocationInfo> VisualLocation)
        {
            string StrZoneName = "";
            List<string> ZoneList = new List<string>();
            List<int> ZoneMaxLoc = new List<int>();
            List<int> ZoneMaxLateral = new List<int>();
            foreach (VisualLocationInfo info in VisualLocation)
            {
                if (info.ZoneID != StrZoneName)
                {
                    StringBuilder ZoneHtml = new StringBuilder();
                    ZoneHtml.AppendFormat("  <div style=\"width:@ZoneWidthpx\" class=\"{0}\"> ", this.SelectColor(info.ZoneID));
                    ZoneHtml.AppendFormat("{0}", this.SilidLocationHtmlCreate(info.ZoneID, VisualLocation));
                    ZoneHtml.Append("<div/>");
                    StrZoneName = info.ZoneID;
                    ZoneList.Add(ZoneHtml.ToString());
                    ZoneMaxLoc.Add(this.MaxLoc);
                    ZoneMaxLateral.Add(this.MaxLateral);
                    this.MaxLoc = 1;
                    this.MaxLateral = 0;
                }
            }
            this.VisualLocationCrated(ZoneList, ZoneMaxLoc, ZoneMaxLateral);
        }

        private void VisualLocationCrated(List<string> ZoneList, List<int> ZoneMaxLoc, List<int> ZoneMaxLateral)
        {
            StringBuilder strHtml = new StringBuilder();
            strHtml.Append(" <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
            for (int i = 0; ZoneList.Count > i; i++)
            {
                int Width = ZoneMaxLoc[i] * 80;
                decimal DivWidth = (decimal.Parse("80") / Width) * 100M;
                strHtml.AppendFormat("<tr><td  >{0}</td></tr>", ZoneList[i].Replace("@ZoneWidth", Width.ToString()).Replace("@DivWidth", DivWidth.ToString()));
                strHtml.Append("<tr><td  class=\"corridor_row\"  >&nbsp;</td><tr/> ");
            }
            strHtml.Append("</table>");
            this.AssignFunctionResponse(this.strZoneColor.ToString() + "@_@" + strHtml.ToString());
        }

        private void ZoneHtmlCreate(List<VisualLocationInfo> VisualLocation)
        {
            string StrZoneName = "";
            List<string> ZoneList = new List<string>();
            List<int> ZoneMaxLoc = new List<int>();
            List<int> ZoneMaxLateral = new List<int>();
            foreach (VisualLocationInfo info in VisualLocation)
            {
                if (info.ZoneID != StrZoneName)
                {
                    StringBuilder ZoneHtml = new StringBuilder();
                    ZoneHtml.AppendFormat("  <div style=\"width:@ZoneWidthpx\" class=\"{0}\"> ", this.SelectColor(info.ZoneID));
                    ZoneHtml.AppendFormat("{0}", this.LocationHtmlCreate(info.ZoneID, VisualLocation));
                    ZoneHtml.Append("<div/>");
                    StrZoneName = info.ZoneID;
                    ZoneList.Add(ZoneHtml.ToString());
                    ZoneMaxLoc.Add(this.MaxLoc);
                    ZoneMaxLateral.Add(this.MaxLateral);
                    this.MaxLoc = 1;
                    this.MaxLateral = 0;
                }
            }
            this.VisualLocationCrated(ZoneList, ZoneMaxLoc, ZoneMaxLateral);
        }
    }
}

